<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    	<title>统战成员学习平台</title>
	    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
	    <link rel="stylesheet" type="text/css" href="../../css/discovery.css" />
	</head>
	<body class="white">
		<div id='app' style="display:none" v-show="true">
			<transition-group name="list" tag="ul" class="dis_com_list">
				<li @click="openWin('moment_detail_win', {studyMomentId: item.studyMomentId})" v-for="item of items" :key="item" class="ui_border_b" :class="{'readed': item.isRead}">
					<img :src="imageBasePath + item.usrImg" onerror="this.src=''">
					<p class="name">{{item.usrName}} <span>{{item.createDate | formatMomentDate}}</span></p>
					<p class="content">{{item.type === 0 ? '赞了你的动态' : '评论了你的动态'}}</p>
				</li>
				<li v-if="loaded" class="no_more" key="-1">已经到底了</li>
			</transition-group>
			<transition name="fade">
				<spinner v-if="loading"></spinner>
			</transition>
		</div>
		<script type="text/javascript" src="../../script/api.js"></script>
		<script type="text/javascript" src="../../script/vue.min.js"></script>
		<script type="text/javascript" src="../../script/common.js"></script>
		<script type="text/javascript" src="../../script/layer_mobile/layer.js"></script>
		<script type="text/javascript">
		    new Vue({
				el: '#app',
		     	data: {
					imageBasePath: imageBasePath,
					items: [],
					loading: false,
					loaded: false,
					pageNum: 1,
					pageSize: 10,
					msgNum: 10,
					voteUserNum: 10
		     	},
				mounted: function() {
		        	var $this = this;
		        	apiready = function() {
						api.parseTapmode();
						$this.getList();
						$this.readAll();

						onScrollToBottom(function () {
							if($this.loaded) return;
							$this.getList()
						})
						api.addEventListener({
						    name: 'readAll_message_event'
						}, function(ret, err){
						    $this.readAll()
						});
                	}
		    	},
		    	methods: {
					getList: function() {
						var $this = this;
						if($this.loading) return;
						$this.loading = true;
						post('/client/studyMoment/msgLog', {
							pageNum: $this.pageNum,
							pageSize: $this.pageSize
						}, function(ret) {
							$this.loading = false;
							if(ret.isSuccess) {
								ret.data.list.forEach(function(item) {
									$this.items.push(item)
								});
								ret.data.isLastPage ? $this.loaded = true : $this.pageNum++;
								parseTapmode();
							} else {
								msgUtil.toast({
								    msg: ret.message
								});
							}
						});
					},
					readAll: function() {
						var $this = this;
						post('/client/studyMoment/readAll', {}, function(ret) {
							if(ret.isSuccess) {
								api.sendEvent({
								    name: 'refresh_newmessagecount_event'
								});
							}
						});
					}
		    	}
		    });
		</script>
	</body>
</html>
